package cn.craftyun.yunexam.mapper;

import cn.craftyun.yunexam.entity.Exam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ExamMapper extends BaseMapper<Exam> {
    @Select("SELECT exam.id,start_time,duration,`name`,`caption` FROM exam,paper WHERE exam.paper_id = paper.id AND start_time <= NOW() ORDER BY start_time DESC limit #{count}")
    List<Map<String, Object>> getActiveExam(@Param("count") Integer count);

    @Select("SELECT exam.id,paper.id paper_id,start_time,duration,`name`,`caption` FROM exam,paper WHERE exam.paper_id = paper.id ORDER BY exam.id")
    IPage<Map<String, Object>> findAllExam(IPage<?> page);
}
